addSchemaItem Method |
This method adds a schema definition to the existing schema dynamically.
Syntax
treeID.addSchemaItem(oSchemaItem)
Parameters
Parameter |
Description |
---|---|
oSchemaItem |
Required. Object that points to an XMLDOM object that contains the schema to be added dynamically to the tree. |
Return Value
No return value.
Remarks
The tree schema consists of generic notations which can identify the items that can be present in the tree. It also contains tags which denote the properties for an item in a tree. Once a schema is defined to thetreeSchemaproperty of the tree, the defined schema can be extended by calling this method.
Example
The following example shows how the above method is used.
<!-- Template of the schema that is to be added dynamically --> <script type ="cordys/xml" id="schemaTemplate"> <TreeItem> <searchPath>Favourites</searchPath> <description>caption</description> <contextMenu>myContext</contextMenu> </TreeItem> </script> <!-- Template of the item to be added to the tree --> <script type ="cordys/xml" id="newItemTemplate"> <Favourites> <id>favourite</id> <description>My Favourites</description> <caption>Favourites</caption> </Favourites> </script> //Function that adds the schema to the existing tree function addNewSchemaItem() { var schemaItem = cordys.loadXmlDocument(cordys.getXML(schematemplate.XMLDocument)); //Add Schema. 'sampletree' denotes the ID of the tree sampletree.addSchemaItem(schemaItem); //Add an item, that depends on the new schema var newItem = cordys.cloneXMLDocument(newItemTemplate.XMLDocument); //Add the item using addItem function to the selected item sampletree.getSelectedItem().getTreeItem().addItem(newItem); //Expand the selected item after addition sampletree.getSelectedItem().expand(); }